/*
*	New C++ File starts here.
*	This file should be named nml_unbounded_array_test_msg.cc
*/

// Include all NML, CMS, and RCS classes and functions
#include "rcs.hh"

// Include command and status message definitions
#include "nml_unbounded_array_test_msg.hh"

// Include externally supplied prototypes
#include "nml_unbounded_array_test_msg_n_codegen_protos.hh"



#ifndef NML_UNBOUNDED_ARRAY_TEST_MSG_NAME_LIST_LENGTH
#define NML_UNBOUNDED_ARRAY_TEST_MSG_NAME_LIST_LENGTH 3
#endif

const NMLTYPE nml_unbounded_array_test_msg_id_list[NML_UNBOUNDED_ARRAY_TEST_MSG_NAME_LIST_LENGTH]= {
	NML_UNBOUNDED_ARRAY_TEST_MSG_TYPE, /* 0,101 */
	NML_UNBOUNDED_ARRAY_TEST_MSG2_TYPE, /* 1,102 */
	-1};
const size_t nml_unbounded_array_test_msg_size_list[NML_UNBOUNDED_ARRAY_TEST_MSG_NAME_LIST_LENGTH]= {
	sizeof(NML_UNBOUNDED_ARRAY_TEST_MSG),
	sizeof(NML_UNBOUNDED_ARRAY_TEST_MSG2),
	0};


// Enumerated Type Constants

/*
Estimated_size	NML_UNBOUNDED_ARRAY_TEST_MSG	144
Estimated_size	NML_UNBOUNDED_ARRAY_TEST_MSG2	176
Estimated_size	s1	16
Estimated_size	s2	48
Estimated_size	MAXIMUM	176
*/
/*
*	NML/CMS Format function : nml_unbounded_array_test_msg_format
*	Automatically generated by NML CodeGen Java Applet.
*	on Wed Nov 21 14:08:13 EST 2007
*/
int nml_unbounded_array_test_msg_format(NMLTYPE type, void *buffer, CMS *cms)
{

	type = cms->check_type_info(type,buffer,"nml_unbounded_array_test_msg",
		(cms_symbol_lookup_function_t) 0,
		(const char **) 0,
		nml_unbounded_array_test_msg_id_list,nml_unbounded_array_test_msg_size_list,
		NML_UNBOUNDED_ARRAY_TEST_MSG_NAME_LIST_LENGTH,
		0);

	switch(type)
	{
	case NML_UNBOUNDED_ARRAY_TEST_MSG_TYPE:
		((NML_UNBOUNDED_ARRAY_TEST_MSG *) buffer)->update(cms);
		break;
	case NML_UNBOUNDED_ARRAY_TEST_MSG2_TYPE:
		((NML_UNBOUNDED_ARRAY_TEST_MSG2 *) buffer)->update(cms);
		break;

	default:
		return(0);
	}
	return 1;
}

/*
*	NML/CMS Update function for NML_UNBOUNDED_ARRAY_TEST_MSG
*	Automatically generated by NML CodeGen Java Applet.
*	on Wed Nov 21 14:08:13 EST 2007
*/
void NML_UNBOUNDED_ARRAY_TEST_MSG::update(CMS *cms)
{

	cms->beginClass("NML_UNBOUNDED_ARRAY_TEST_MSG","NMLmsg");
	cms->beginClassVar("s2_m");
	nmlupdate(cms,((struct s2 *)&s2_m));
	cms->endClassVar("s2_m");
	cms->update_unbounded_with_name("f_ubP",&f_ubP,f_ubP_length,f_ubP_size_allocated);
	cms->beginStructUnboundedArray("s2_ubP",((void **) &s2_ubP),s2_ubP_length,s2_ubP_size_allocated,sizeof(struct s2));
	if(0 != s2_ubP)
	{
		for(int i_s2_ubP=0; i_s2_ubP < s2_ubP_length && i_s2_ubP < s2_ubP_size_allocated ; i_s2_ubP++)
		{
			cms->beginStructArrayElem("s2_ubP", i_s2_ubP);
			nmlupdate(cms,&s2_ubP[i_s2_ubP]);
			cms->endStructArrayElem("s2_ubP", i_s2_ubP);
		}
	}
	cms->endStructUnboundedArray("s2_ubP",((void **) &s2_ubP),s2_ubP_length,s2_ubP_size_allocated,sizeof(struct s2));

	cms->endClass("NML_UNBOUNDED_ARRAY_TEST_MSG","NMLmsg");

}


/*
*	NML/CMS Update function for NML_UNBOUNDED_ARRAY_TEST_MSG2
*	Automatically generated by NML CodeGen Java Applet.
*	on Wed Nov 21 14:08:13 EST 2007
*/
void NML_UNBOUNDED_ARRAY_TEST_MSG2::update(CMS *cms)
{

	cms->beginClass("NML_UNBOUNDED_ARRAY_TEST_MSG2","NMLmsg");
	cms->update_with_name("pad25",pad25,25);
	cms->beginClassVar("s2_m");
	nmlupdate(cms,((struct s2 *)&s2_m));
	cms->endClassVar("s2_m");
	cms->update_unbounded_with_name("f_ubP",&f_ubP,f_ubP_length,f_ubP_size_allocated);
	cms->beginStructUnboundedArray("s2_ubP",((void **) &s2_ubP),s2_ubP_length,s2_ubP_size_allocated,sizeof(struct s2));
	if(0 != s2_ubP)
	{
		for(int i_s2_ubP=0; i_s2_ubP < s2_ubP_length && i_s2_ubP < s2_ubP_size_allocated ; i_s2_ubP++)
		{
			cms->beginStructArrayElem("s2_ubP", i_s2_ubP);
			nmlupdate(cms,&s2_ubP[i_s2_ubP]);
			cms->endStructArrayElem("s2_ubP", i_s2_ubP);
		}
	}
	cms->endStructUnboundedArray("s2_ubP",((void **) &s2_ubP),s2_ubP_length,s2_ubP_size_allocated,sizeof(struct s2));

	cms->endClass("NML_UNBOUNDED_ARRAY_TEST_MSG2","NMLmsg");

}


/*
*	NML/CMS Update function for s1
*	Automatically generated by NML CodeGen Java Applet.
*	on Wed Nov 21 14:08:13 EST 2007
*/
void nmlupdate(CMS *cms,s1 *x)
{

	cms->beginClass("s1",0);
	cms->update_with_name("i",x->i);
	cms->update_with_name("d",x->d);

	cms->endClass("s1",0);

}


/*
*	NML/CMS Update function for s2
*	Automatically generated by NML CodeGen Java Applet.
*	on Wed Nov 21 14:08:13 EST 2007
*/
void nmlupdate(CMS *cms,s2 *x)
{

	cms->beginClass("s2",0);
	cms->beginStructUnboundedArray("s1_in_s2_ubP",((void **) &x->s1_in_s2_ubP),x->s1_in_s2_ubP_length,x->s1_in_s2_ubP_size_allocated,sizeof(struct s1));
	if(0 != x->s1_in_s2_ubP)
	{
		for(int i_s1_in_s2_ubP=0; i_s1_in_s2_ubP < x->s1_in_s2_ubP_length && i_s1_in_s2_ubP < x->s1_in_s2_ubP_size_allocated ; i_s1_in_s2_ubP++)
		{
			cms->beginStructArrayElem("s1_in_s2_ubP", i_s1_in_s2_ubP);
			nmlupdate(cms,((struct s1 *)&x->s1_in_s2_ubP[i_s1_in_s2_ubP]));
			cms->endStructArrayElem("s1_in_s2_ubP", i_s1_in_s2_ubP);
		}
	}
	cms->endStructUnboundedArray("s1_in_s2_ubP",((void **) &x->s1_in_s2_ubP),x->s1_in_s2_ubP_length,x->s1_in_s2_ubP_size_allocated,sizeof(struct s1));
	cms->update_unbounded_with_name("c_ubP",&x->c_ubP, x->c_ubP_length, x->c_ubP_size_allocated);

	cms->endClass("s2",0);

}

/*
*	Constructor for NML_UNBOUNDED_ARRAY_TEST_MSG
*	Automatically generated by NML CodeGen Java Applet.
*	on Wed Nov 21 14:08:13 EST 2007
*/
NML_UNBOUNDED_ARRAY_TEST_MSG::NML_UNBOUNDED_ARRAY_TEST_MSG()
	: NMLmsg(NML_UNBOUNDED_ARRAY_TEST_MSG_TYPE,sizeof(NML_UNBOUNDED_ARRAY_TEST_MSG))
{
	initialize_s2( &(s2_m));
	f_ubP=0;
	f_ubP_length=0;
	f_ubP_size_allocated=0;
	s2_ubP=0;
	s2_ubP_length=0;
	s2_ubP_size_allocated=0;

}

/*
*	Constructor for NML_UNBOUNDED_ARRAY_TEST_MSG2
*	Automatically generated by NML CodeGen Java Applet.
*	on Wed Nov 21 14:08:13 EST 2007
*/
NML_UNBOUNDED_ARRAY_TEST_MSG2::NML_UNBOUNDED_ARRAY_TEST_MSG2()
	: NMLmsg(NML_UNBOUNDED_ARRAY_TEST_MSG2_TYPE,sizeof(NML_UNBOUNDED_ARRAY_TEST_MSG2))
{
	for(int i_pad25=0; i_pad25< 25; i_pad25++)
	{
		((char*)pad25)[i_pad25]  = (char) 0;
	}
	initialize_s2( &(s2_m));
	f_ubP=0;
	f_ubP_length=0;
	f_ubP_size_allocated=0;
	s2_ubP=0;
	s2_ubP_length=0;
	s2_ubP_size_allocated=0;

}

/*
*	Initializer for s1
*	Automatically generated by NML CodeGen Java Applet.
*	on Wed Nov 21 14:08:13 EST 2007
*/
void initialize_s1(s1* x)
{
	x->i = (int) 0;
	x->d = (double) 0;

}

/*
*	Initializer for s2
*	Automatically generated by NML CodeGen Java Applet.
*	on Wed Nov 21 14:08:13 EST 2007
*/
void initialize_s2(s2* x)
{
	x->s1_in_s2_ubP=0;
	x->s1_in_s2_ubP_length=0;
	x->s1_in_s2_ubP_size_allocated=0;
	x->c_ubP=0;
	x->c_ubP_length=0;
	x->c_ubP_size_allocated=0;

}

